home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_04
/
1004010d
< prev
next >
Wrap
Text File
|
1992-03-03
|
351b
|
17 lines
/* ldiv function */
#include <stdlib.h>
ldiv_t (ldiv)(long numer, long denom)
{ /* compute long quotient and remainder */
ldiv_t val;
val.quot = numer / denom;
val.rem = numer - denom * val.quot;
if (val.quot < 0 && 0 < val.rem)
{ /* fix remainder with wrong sign */
val.quot += 1;
val.rem -= denom;
}
return (val);
}